import taos
conn = taos.connect(
    host="192.168.100.251",
    user="root",
    password="taosdata",
    port=6030,
)
# 数据库名称
db = "wlw"
# db = "Second_group"
# 如果存在这个数据库那么就删除
# conn.execute(f"DROP DATABASE IF EXISTS {db}")
# # 如果不存在这个数据库就创建
# conn.execute(f"CREATE DATABASE {db}")

# 使用这个数据库
conn.select_db(db)

# 定义创建超级表的SQL命令
create_stable_sql = """
DESCRIBE iot;
"""


# CREATE STABLE iot (
#     ts TIMESTAMP,
#     `value` FLOAT
# ) TAGS (
#     code NCHAR(256)
# );



# create super table
conn.execute(create_stable_sql)



# # 定义插入数据库的数据
# point_code = 24060406290001
# ptype = 51
# value = 55762
# mystable = 'mystable'
# db_table = f'{point_code}_{ptype}_float'
# # 链接数据库sql语句
# sql = f"""insert into `{db_table}` using {mystable} tags("{db_table}") values(now, "{value}")"""
# conn.execute(sql)



# 关闭数据库
conn.close()